package com.file.common;

import com.google.common.collect.Sets;

import java.util.Set;

/**
 * Created by 95577 on 2018/3/22.
 */
public class Const {

    public static final String CURRENT_USER = "currentUser";

    public static final String EMAIL = "email";
    public static final String USERNAME = "USERNAME";


    public interface  ProductListOrderBy {
        Set<String> PRICE_ASC_DESC = Sets.newHashSet("price_desc", "asc");
    }

    public interface Cart {
        // 购物车选中状态
        int CHECKED = 1;
        // 购物车未选中状态
        int UN_CHECKED = 0;

        // 限制 失败
        String LIMIT_NUM_FAIL = "LIMIT_NUM_FAIL";
        // 限制 成功
        String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
    }

    public interface Role {
        // 普通用户
        int ROLE_CUSTOMER = 0;
        // 管理员账户
        int ROLE_ADMIN = 1;
    }

    public interface alipayCallback {
        //
        String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        //
        String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";
        // 交易支付成功（返回支付宝成功）
        String TRADE_SUCCESS = "success";
        // 返回支付宝失败
        String TRADE_FINISHED = "failed";
    }

    public enum  PaymentTypeEnum {

        ONLINE_PAY(1, "在线支付");

        private String value;
        private int code;
        PaymentTypeEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static PaymentTypeEnum codeOf(int code) {
            for(PaymentTypeEnum paymentTypeEnum : values()) {
                if (paymentTypeEnum.getCode() == code) {
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应支付枚举");
        }
    }

    public  enum  PayPlatFornenum {

        ALPAY(1, "支付宝");

        private String value;
        private int code;
        PayPlatFornenum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }
    }

    public  enum  orderStatusEnum {
        CANCELED(0, "已取消"),
        NO_PAY(10, "未支付"),
        PAID(20, "已支付"),
        SHIPPED(30, "已发货"),
        ORDER_SUCCESS(50, "订单完成"),
        PRDER_CLOSED(60, "订单关闭");

        orderStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }


        public static orderStatusEnum codeOf(int code) {
            for(orderStatusEnum orderStatusEnum : values()) {
                if (orderStatusEnum.getCode() == code) {
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有找到对应订单状态枚举");
        }

    }

    public enum productStatusEnum {
        ON_SALE(1, "在线");
        private String value;
        private int code;
        productStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }
    }
}
